package sg.edu.nus.dashboard.util
{
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	
	import sg.edu.nus.dashboard.main.model.AppModelLocator;

	public class SQLUtil
	{
		public function SQLUtil()
		{
		}
		
		public static function translate(arr:ArrayCollection):String {
			
			var result:String = "";
			
			// construct metadata string
			var metaArr:ArrayCollection = ArrayCollection(arr.getItemAt(0, 0));
			for each (var object:Object in metaArr) {
				result += "\t" + object.toString() + "\t";
			}
			
			
			// add seperator
			result += "\n-----------------------------------------------------------------" +
				"-------------------------------------------------------------------------" +
				"-------------------------------------------------------------------------" +
				"------------------------------------------------\n";
			
			// construct data string
			var i:int = 1;
			for(i = 1; i < arr.length; i++) {
				var temp:ArrayCollection = ArrayCollection(arr.getItemAt(i, 0));
				for each (object in temp) {
					if(null != object)
						result += "\t" + object.toString() + "\t";
					else
						result += "\t\t\t";
				}
				result += "\n";
			}
			
			return result;
		}
		
	}
}